home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
COMMUNIC
/
MRUN211.ZIP
/
MRUN211E.WAS
< prev
next >
Wrap
Text File
|
1993-05-01
|
20KB
|
745 lines
;MailRun v2.11: Part E, addulfile
;1992-1993 Gerald P. Sully, all rights reserved.
#comment
**************************************************************************
**************************************************************************
*
* This file contains routines related to adding a "Upload File"
* item to a mailrun. It puts up the Upload Files dialog box,
* which displays the contents of the available files index (the
* *.udx file for the mailrun). When a file is selected from the
* list, a detailed description is displayed from the *.ubf file
* for the mailrun).
*
**************************************************************************
**************************************************************************
#endcomment
#define MRUN211E
#define MRUN211DE
#include "mrun211.h"
string DXFileTabs, OldUDX, OldUBF, MRunUDX, MRunUBF, LastChoice
string UploadDir, DownloadDir, BBSChoice
integer InULDir, ULSortField
#comment
*********************************************************************
*
* MAIN()
*
* Calls checkchild(), updateudx(), interfaceon(), getnewdesc(),
* getulfiles(), checkchanged(), getlastitem(), gettaskstring(),
* clearfiledesc(), makebbslist(), ulfilebox(), insertulfile(),
* delulfile(), menudim(), makefullname(), sortidx(), checkfile()
*
* Adds a SendFile item to the mailrun. An feditbox is
* used to display the file description in order to take
* advantage of wordwrap. The flistbox displays the
* contents of MAILRUN.UDX, which contains information on
* any file downloaded by MailRun, plus additional files
* found in the upload directory. A file description must
* be at least 6 characters, but may be as long as needed.
*
*********************************************************************
#endcomment
proc main
string FullFileName, char, temp
integer dialogstatus
integer j, InUDX
menudim()
checkchild()
findfirst MailRun
MailRunTrunc = $FILENAME
DXFileTabs = "58,92,130,305,315,319,322,325,328"
profilerd MailRun "MailRun" "UploadDir" UploadDir
profilerd MailRun "MailRun" "DownloadDir" DownloadDir
profilerd MailRun "MailRun" "ULSortField" ULSortField
strextract BBSChoice TaskItem "`t" 3
strextract char TaskItem "`t" 4
atoi char j
FileDesc = makefullname(TempDir, "DESC.TMP")
OldUDX = makefullname(TempDir, "OLDUDX.TMP")
OldUBF = makefullname(TempDir, "OLDUBF.TMP")
MRunUDX = makefullname(MailRunDir, "MAILRUN.UDX")
MRunUBF = makefullname(MailRunDir, "MAILRUN.UBF")
if isfile FileDesc
delfile FileDesc
endif
if not (checkfile(MRunUDX) && checkfile(MRUNUBF))
getulfiles()
endif
LastChoice = ""
FLAGS &= UNCHANGED
interfaceon()
makebbslist()
ulfilebox()
dialogstatus = $DIALOG
while dialogstatus != 1
switch dialogstatus
case 10
;User selected "Add"
insertulfile(&j)
TaskItem = gettaskstring(BBSChoice, j)
endcase
case 11
;User selected "Save"
if FLAGS & CHANGED
updateudx()
FLAGS &= UNCHANGED
updatedlg -1
endif
endcase
case 12
;User selected "Delete"
delulfile()
endcase
case 13
;User selected "Refresh"
statmsg "Refreshing Uploads List from Upload Directory..."
getulfiles()
updatedlg -1
statmsg ""
endcase
case 50
;User selected a sort radiobutton
profilewr MailRun "MailRun" "ULSortField" ULSortField
sortidx(MRunUDX, ULSortField)
updatedlg 16
endcase
case 130
;User selected a file from the listbox
if checkchanged()
getnewdesc()
updatedlg 137
else
FileChoice = LastChoice
updatedlg 16
endif
endcase
case 170
;User changed BBSs with the combobox
j = getlastitem(BBSChoice)
TaskItem = gettaskstring(BBSChoice, j)
endcase
case 230
;User entered a name in the File Name box
FullFileName = makefullname(UploadDir, FileName)
if isfile FullFileName
InULDir = 1
else
InULDir = 0
endif
interfaceoff()
openfile(MRunUDXFile, MRunUDX, _READWRITE, _TEXT)
InUDX = checkudx(FileName)
if InUDX
fseek MRunUDXFile -100 1
fgets MRunUDXFile FileChoice
fgets MRunUDXFile FileChoice
strextract temp FileChoice "`t" 0
while not strcmpi temp FileName
fgets MRunUDXFile FileChoice
strextract temp FileChoice "`t" 0
endwhile
endif
fclose MRunUDXFile
interfaceon()
if InUDX
makedesc(MRunUBF)
else
clearfiledesc()
endif
updatedlg -1
endcase
case 250
;User entered a file description
if !(FLAGS & CHANGED)
FLAGS |= CHANGED
endif
endcase
endswitch
dialogstatus = $DIALOG
endwhile
endproc
#comment
*********************************************************************
*
* INSERTULFILE()
*
* Called by main()
*
* Calls openfile(), updateudx(), insertitem(),
* interfaceon(), interfaceoff(), makefullname(), checkudx(),
* clearfiledesc(), shortdesc()
*
* Adds a SendFile item to the *.MRN file and the task list.
*
*********************************************************************
#endcomment
proc insertulfile
intparm j
string ULDescString, ULFileString, FullFileName
string ULFileSpec, StatString, CopyboxMsg
integer ULDescLength, Perm, Response, InUDX
interfaceoff()
if NULLSTR FileName
;User hasn't selected a file
usermsg "You must select a file first."
return
endif
if InULDir == 0
strupr FileName
strfmt CopyBoxMsg \
"%s is not in the Upload Directory.`r`nCopy it now?" \
FileName
strlwr FileName
sdlgmsgbox "MailRun Message" CopyBoxMsg QUESTION \
OKCANCEL Response 1
switch Response
case 1
;User selected "OK"
ULFileSpec = makefullname(DownloadDir, FileName)
dir ULFileSpec FullFileName
if NULLSTR FullFileName
return
endif
if not isfile FullFileName
sdlgmsgbox "MailRun Message" "No such file!" \
EXCLAMATION OK Response 1
return
endif
copyfile FullFileName UploadDir
if not strcmpi ULFileSpec FullFileName
;if the user chose a file other than the one specified
;get the name of the file
findfirst FullFileName
FileName = $FILENAME
strlwr FileName
;determine whether it is already in the uploads database
openfile(MRunUDXFile, MRunUDX, _READWRITE, _TEXT)
InUDX = checkudx(FileName)
fclose MRunUDXFile
if InUDX == 0
;if it isn't in the uploads database, put it there
clearfiledesc()
FLAGS |= CHANGED
updateudx()
endif
endif
InULDir = 1
updatedlg -1
endcase
case 2
;User selected "Cancel"
return
endcase
endswitch
endif
;No description may be less than 6 characters
openfile(FileDescFile, FileDesc, _READWRITE, _NORMAL)
fread FileDescFile ULDescString 65 ULDescLength
fclose FileDescFile
if ULDescLength < 6
usermsg "Please enter a longer description."
elseif shortdesc(ULDescString, ULDescLength)
;If everything is OK...
if FLAGS & CHANGED
;Add the new description to the database
updateudx()
FLAGS &= UNCHANGED
updatedlg 16
endif
Perm = 2 - PermRadio
strupr FileName
strfmt ULFileString \
"1,%d,SendFile,%s,%s" Perm FileName Conf
strfmt StatString \
"Added to %s: `"Upload %s to Conference %s`"" \
BBSChoice FileName Conf
j++
insertitem(BBSChoice, j, ULFileString)
strlwr FileName
statmsg StatString
endif
interfaceon()
endproc
#comment
*********************************************************************
*
* SHORTDESC()
*
* Called by insertulfile()
*
* Calls findstring()
*
* If the current BBS type is WildCat! or RBBS, limits the
* upload description length to 60 or 45 characters,
* respectively. Gives user an opportunity to enter a new
* description if the current one is too long.
*
*********************************************************************
#endcomment
func shortdesc : integer
strparm ULDescString
intparm ULDescLength
string ULMsg, TypeName
integer Response, MaxL